/*
* Creating date: 10-Jun-2014
* Last modifying date:
* Author: Nguyen Trong Viet
*/

/*
 * Description: This file contains the API to control SSD1289 chip by FSMC interface
 * Please find the detail in attached document
 */

#ifndef __STM32F4XX_SSD1289_H
#define __STM32F4XX_SSD1289_H

#ifdef __cplusplus
    extern "C" {
#endif

#include "stm32f4xx.h"
#include "stm32f4xx_fsmc.h"
#include "stm32f4xx_Types.h"
#include "Delay.h"


/* Define the memory address for writing register*/
#define Write_Reg    ((volatile unsigned short *) 0x60000000u)

/* Define the memory address for writing RAM data */
#define Write_RAM    ((volatile unsigned short *) 0x60020000u)

/* Define the maximum row address (1st row is 0) */
#define Max_Row		 ((UIN16) 319)

/* Define the maximum column address */
#define Max_Col		 ((UIN16) 240)

#define NormalWin	 ((UIN16) 0x6830u)

#define SmallWin	 ((UIN16) 0x7030u)

/******************************************************************
 *** 	THIS AREA IS FOR DEFINING SSD1289 LCD REGISTERS INDEX	***
 ******************************************************************/
#define Oscillation_Start			((UIN16) 0x00u)
#define Driver_Output_Control		((UIN16) 0x01u)
#define LCD_Drive_AC_Control		((UIN16) 0x02u)
#define Power_Control_1				((UIN16) 0x03u)
#define Compare_Register_1			((UIN16) 0x05u)
#define	Compare_Register_2			((UIN16) 0x06u)
#define Display_Control				((UIN16) 0x07u)
#define Frame_Cycle_Control			((UIN16) 0x0Bu)
#define Power_Control_2			 	((UIN16) 0x0Cu)
#define Power_Control_3			 	((UIN16) 0x0Du)
#define Power_Control_4			 	((UIN16) 0x0Eu)
#define Gate_Scan_Start_Position 	((UIN16) 0x0Fu)
#define Sleep_Mode					((UIN16) 0x10u)
#define Entry_Mode					((UIN16) 0x11u)
#define Optimize_Access_Speed_3		((UIN16) 0x12u)
#define Generic_Interface_Contrl	((UIN16) 0x15u)
#define Horizontal_Porch			((UIN16) 0x16u)
#define Vertical_Porch				((UIN16) 0x17u)
#define Power_Control_5				((UIN16) 0x1Eu)
#define RAM_Data					((UIN16) 0x22u)
#define RAM_Data_Mask_1				((UIN16) 0x23u)
#define RAM_Data_Mask_2				((UIN16) 0x24u)
#define Frame_Frequency				((UIN16) 0x25u)
#define Horizontal_RAM_Address		((UIN16) 0x44u)
#define Vertical_RAM_Address_Start  ((UIN16) 0x45u)
#define Vertical_RAM_Address_End	((UIN16) 0x46u)
#define X_Address					((UIN16) 0x4Eu)
#define Y_Address					((UIN16) 0x4Fu)
/************************ END OF DEFINING SSD1289 LCD REGISTERS INDEX ****************/



inline void SSD1289_RCC_Init(void);
inline void SSD1289_Para_Init(void);
inline void SSD1289_Init(void);
inline void SSD1289_IO_Init(void);
inline void SSD1289_WriteReg(UIN16 Reg_Add, UIN16 Reg_Value);
inline void SSD1289_WritePixel(UIN16 Pix_Value);
inline void SSD1289_Reg_Init(void);
inline void SSD1289_IO_Test(void);
inline void SSD1289_SetWindow(struct LCD_Coord* Pos);
inline void SSD1289_CloseWindow(void);


#ifdef __cplusplus
    }
#endif

#endif
